extends Area2D

@onready var body: CharacterBody2D = $"../邮车"
var flag_bool=false;
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	pass

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:

	pass

# 当有物体进入Area2D时调用
func _body_entered(body: Node2D) -> void:
	# 检查进入的物体是否是Player（CharacterBody2D类型）
	if body is CharacterBody2D:
		flag_bool=true;
		# 调用Player的回调函数（如果存在）
		if body.has_method("_on_area_2d_body_entered"):
			print("a")
			body._on_area_2d_body_entered(self)

# 当有物体离开Area2D时调用
func _body_exited(body: Node2D) -> void:
	
	# 检查离开的物体是否是Player（CharacterBody2D类型）
	if body is CharacterBody2D:
		flag_bool=false;
		# 调用Player的回调函数（如果存在）
		if body.has_method("_on_area_2d_body_exited"):
			print("b")
			body._on_area_2d_body_exited(self)
func queue_free_in(delay: float) -> void:
	await get_tree().create_timer(2.0).timeout
	await get_tree().create_timer(delay).timeout;
	queue_free();
	print("自动清理Area2D：", name);
